<% layout('/layouts/default.html', {title: '系统与文件柜交互记录表管理', libs: ['dataGrid']}){ %>
<div class="main-content">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-notebook"></i> ${text('系统与文件柜交互记录表管理')}
            </div>
            <div class="box-tools pull-right">
                <a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
                <% if(hasPermi('sd:fileCabinetRecord:edit')){ %>
                <a href="${ctx}/sd/fileCabinetRecord/form" class="btn btn-default btnTool" title="${text('新增系统与文件柜交互记录表')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
                <% } %>
            </div>
        </div>
        <div class="box-body">
            <#form:form id="searchForm" model="${fileCabinetRecord}" action="${ctx}/sd/fileCabinetRecord/selectStatusListData" method="post" class="form-inline hide"
            data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
            <div class="form-group">
                <label class="control-label">${text('流程代号')}：</label>
                <div class="control-inline">
                    <#form:input path="processCode" maxlength="100" class="form-control width-120"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">${text('操作人警号')}：</label>
                <div class="control-inline">
                    <#form:input path="policeno" maxlength="60" class="form-control width-120"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">${text('操作人姓名')}：</label>
                <div class="control-inline">
                    <#form:input path="userName" maxlength="60" class="form-control width-120"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">${text('操作人')}：</label>
                <div class="control-inline">
                    <#form:input path="userFace" maxlength="1000" class="form-control width-120"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">${text('柜号')}：</label>
                <div class="control-inline">
                    <#form:input path="cabinetno" maxlength="5" class="form-control width-120"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">${text('响应类型')}：</label>
                <div class="control-inline width-120">
                    <#form:select blankOption="true" path="responseType" dictType="sd_file_cabinet_response_type"  class="form-control"/>
                </div>
            </div>
<!--            <div class="form-group">-->
<!--                <label class="control-label">${text('响应状态')}：</label>-->
<!--                <div class="control-inline width-120">-->
<!--                    <#form:select blankOption="true" path="responseStatus" dictType="sd_file_cabinet_response_status"  class="form-control"/>-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">
                <label class="control-label">${text('记录产生日期')}：</label>
                <div class="control-inline">
                    <#form:input path="recordDate" readonly="true" maxlength="20" class="form-control laydate width-datetime"
                    dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm"/>
                </div>
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
                <button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
            </div>
        </#form:form>
        <table id="dataGrid"></table>
        <div id="dataGridPage"></div>
    </div>
</div>
</div>
<% } %>
<script>
    // 初始化DataGrid对象
    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        columnModel: [
            {header:'${text("流程代号")}', name:'processCode', index:'a.process_code', width:150, align:"center", frozen:true , formatter: function(val, obj, row, act){
                    return '<a href="#" data-click-binded="false" title="${text("点击查看该流程所有记录")}" onclick="selectProcessCode(\''+row.processCode+'\')" >'+val+'</a>'
                }},
            {header:'${text("操作人警号")}', name:'policeno', index:'a.policeno', width:150, align:"center"},
            {header:'${text("操作人姓名")}', name:'userName', index:'a.user_name', width:100, align:"center"},
            {header:'${text("操作人")}', name:'userFace', index:'a.user_face', width:150, align:"center" ,formatter: function(val, obj, row, act){
                    if(val==null){
                        return "图片丢失";
                    }else {
                        return '<img id="avatarImg" title="${text("点击放大查看")}" onclick="showImg(\''+val+'\')" class=" img-responsive img-circle" src="'+val+'">';
                    }
                }},
            {header:'${text("柜号")}', name:'cabinetno', index:'a.cabinetno', width:100, align:"center"},
            {header:'${text("响应类型")}', name:'responseType', index:'a.response_type', width:150, align:"center",formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('sd_file_cabinet_response_type')}, val, '${text("未知")}', true);
                }},
            {header:'${text("响应状态")}', name:'responseStatus', index:'a.response_status', width:100, align:"center" ,formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('sd_file_cabinet_response_status')}, val, '${text("未知")}', true);
                }},
            {header:'${text("备注")}', name:'remark', index:'a.remark', width:150, align:"center"},
            {header:'${text("记录产生日期")}', name:'recordDate', index:'a.record_date', width:180, align:"center"},
            {header:'${text("操作")}', name:'actions', width:80, sortable:false, title:false, formatter: function(val, obj, row, act){
                var actions = [];
                <% if(hasPermi('sd:docRecv:edit')){ %>
                        const type = row.responseType;
                        let firstTitle = '模拟开门成功';
                        let secondTitle = '模拟开门失败';
                        if ('3' === type) {
                            firstTitle = '模拟关门成功';
                            secondTitle = '模拟关门失败';
                        }
                        actions.push('<a href="${ctx}/sd/simulateThirdParty/send?processCode='+row.processCode+'&responseStatus='+"1"+'&responseType='+row.responseType+'" class="btnList" data-confirm="${text("确认执行操作")}" title=' + firstTitle + ' ><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
                        actions.push('<a href="${ctx}/sd/simulateThirdParty/send?processCode='+row.processCode+'&responseStatus='+"2"+'&responseType='+row.responseType+'" class="btnList" data-confirm="${text("确认执行操作")}" title=' + secondTitle + '><i class="glyphicon glyphicon-remove-circle"></i></a>&nbsp;');

                    <% } %>
                    return actions.join('');
                }
            }
        ],
        // 加载成功后执行事件
        ajaxSuccess: function(data){
        }
    });

    // 查找同一流程记录
    function selectProcessCode(processCode){
        $("#processCode").val(processCode).trigger('change');
        page();
    };

    // 查看人脸图像
    function showImg(src) {
        js.layer.open({
            type: 2,
            shade: 0.8,
            //area: [(js.layer.window.outerWidth-900)+'px',(js.layer.window.outerHeight-220)+'px'],
            area:  ['555px', '505px'],
            title: '',
            resize: false,
            scrollbar: false,
            maxmin:false,
            content: '${ctx}/a/sd/collectPicture/showImg?src='+src,
            success: function(layero, index){
            },


        });
    }
</script>